// import React, { useEffect, useState } from 'react'
// import { Switch, Route, Redirect } from 'react-router-dom'
// import axios from 'axios'
// import Home from '../../../views/sandBox/home/Home'
// import UserList from '../../../views/sandBox/user-manage/UserList'
// import RoleList from '../../../views/sandBox/right-manage/RoleList'
// import RightList from '../../../views/sandBox/right-manage/RightList'
// import NewsAdd from '../../../views/sandBox/news-manage/add/NewsAdd'
// import NewsCategory from '../../../views/sandBox/news-manage/category/NewsCategory'
// import NewsDraft from '../../../views/sandBox/news-manage/draft/NewsDraft'
// import Audit from '../../../views/sandBox/audit-manage/audit/Audit'
// import AuditList from '../../../views/sandBox/audit-manage/list/AuditList'
// import Unpublished from '../../../views/sandBox/publish-manage/unpublished/Unpublished'
// import Published from '../../../views/sandBox/publish-manage/published//Published'
// import Sunset from '../../../views/sandBox/publish-manage/sunset//Sunset'
// import NoPermission from '../../../views/sandBox/nopermission/NoPermission'
// import NewsPreview from '../../../views/sandBox/news-manage/preview/NewsPreview'
// import NewsUpdate from '../../../views/sandBox/news-manage/update/NewsUpdate'
// import { Spin } from 'antd'
// import { connect } from 'react-redux';
// const LocalRouterMap = {
//   "/home": Home,
//   "/user-manage/list": UserList,
//   "/right-manage/role/list": RoleList,
//   "/right-manage/right/list": RightList,
//   "/news-manage/add": NewsAdd,
//   "/news-manage/draft": NewsDraft,
//   "/news-manage/category": NewsCategory,
//   "/news-manage/preview/:id": NewsPreview,
//   "/news-manage/update/:id": NewsUpdate,
//   "/audit-manage/audit": Audit,
//   "/audit-manage/list": AuditList,
//   "/publish-manage/unpublished": Unpublished,
//   "/publish-manage/published": Published,
//   "/publish-manage/sunset": Sunset
// }
// function NewRouter(props) {
//   const [BackRouterList, setBackRouterList] = useState([])

//   useEffect(() => {
//     Promise.all([
//       axios.get("/rights"),
//       axios.get("/children"),
//     ]).then(res => {
//       // console.log(res);
//       setBackRouterList([...res[0].data, ...res[1].data])
//     })
//   }, [])
//   const checkRoute = (item) => {
//     return LocalRouterMap[item.key] && (item.pagepermisson || item.routepermisson)
//   }
//   const checkUserPermission = (item) => {
//     return rights.includes(item.key)
//   }
//   const { role: { rights } } = JSON.parse(localStorage.getItem("token"))
//   return (
//     <Spin tip="Loading" size="small" spinning={props.isLoading}>
//       <Switch>
//         {
//           BackRouterList.map(item => {
//             if (checkRoute(item) && checkUserPermission(item)) {
//               return <Route path={item.key} key={item.id} component={LocalRouterMap[item.key]} exact></Route>
//             }
//             return null

//           })
//         }

//         <Redirect from="/" to="/home" exact />
//         {
//           BackRouterList.length > 0 ? <Route path="*" component={NoPermission}></Route> : ""
//         }

//       </Switch>
//     </Spin>

//   )
// }
// const mapStateToProps = ({ loadReducer: { isLoading } }) => {
//   return {
//     isLoading
//   }
// }
// export default connect(mapStateToProps)(NewRouter)
import React from 'react'
import { Redirect, Route, Switch } from 'react-router-dom'
import Workbench from '../../views/workbench/Workbench'
import DeviceInstall from '../../views/deviceOperate/deviceInstall/DeviceInstall'
import DeviceNew from '../../views/deviceOperate/deviceNew/DeviceNew'
import DevCheck from '../../views/deviceOperate/devcheck/DevCheck'
import DevDown from '../../views/deviceOperate/devdown/DevDown'
import DevMaintain from '../../views/deviceOperate/devmaintain/DevMaintain'
import DevInfo from '../../views/deviceManage/devInfo/DevInfo'
import DevMonitor from '../../views/deviceManage/devMonitor/DevMonitor'
import CardInfo from '../../views/cardManage/cardinfo/CardInfo'
import CardMonitor from '../../views/cardManage/cardmonitor/CardMonitor'
import Infoboard from '../../views/targetManage/Infoboard'
import MaterialManage from '../../views/materialManage/MaterialManage'
import AppManage from '../../views/operation/app/AppManage'
import collectSmart from '../../views/operation/collect/collectSmart'
import DevDiagnosis from '../../views/operation/devDiagnosis/DevDiagnosis'
import { HashRouter } from 'react-router-dom/cjs/react-router-dom.min'
import Workbench_ex from '../../views/workbench/Workbench_ex'
export default function NewRouter(props) {
  return (
    <HashRouter>
      <Switch>
        <Route path="/workbench" component={Workbench}></Route>
        <Route path="/devoperate/devnew" component={DeviceNew}></Route>
        <Route path="/devoperate/devinstall" component={DeviceInstall}></Route>
        <Route path="/devoperate/devcheck" component={DevCheck}></Route>
        <Route path="/devoperate/devmaintain" component={DevMaintain}></Route>
        <Route path="/devoperate/devdown" component={DevDown}></Route>
        <Route path="/devmanage/devinfo" component={DevInfo}></Route>
        <Route path="/devmanage/devmonitor" component={DevMonitor}></Route>
        <Route path="/cardmanage/cardinfo" component={CardInfo}></Route>
        <Route path="/cardmanage/cardmonitor" component={CardMonitor}></Route>
        <Route path="/targetmanage/infoboard" component={Infoboard}></Route>
        <Route path="/materialmanage/materialist" component={MaterialManage}></Route>
        <Route path="/operation/app" component={AppManage}></Route>
        <Route path="/operation/devdiagnosis" component={DevDiagnosis}></Route>
        <Route path="/operation/collect" component={collectSmart}></Route>
        <Route path="/workbenchex" component={Workbench_ex}></Route>
        <Redirect from="/" to="/workbench"></Redirect>
      </Switch>
    </HashRouter>


  )
}

